package com.wyb.springcloud.demo.eurekaconsumerfeignhystrix.controller;


import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class DcController {

    @Autowired
    ConsumerService consumerService;

    @GetMapping("/consumer")
    public String dc() {
        return consumerService.consumer();
    }
}

@Component(value = "consumerService")
class ConsumerService {

    @Autowired
    DcClient dcClient;

    @HystrixCommand(fallbackMethod = "fallback")
    public String consumer() {
        return dcClient.consumer();
    }

    public String fallback() {
        return "fallback";
    }

}

